package com.mall.common.enums;

/**
 * 登出原因枚举
 */
public enum LogoutReasonEnum {
    
    /**
     * 主动登出
     */
    ACTIVE_LOGOUT("active_logout", "主动登出"),
    
    /**
     * 强制下线
     */
    FORCE_LOGOUT("force_logout", "强制下线"),
    
    /**
     * Token过期
     */
    TOKEN_EXPIRED("token_expired", "Token过期"),
    
    /**
     * 账号被禁用
     */
    ACCOUNT_DISABLED("account_disabled", "账号被禁用"),
    
    /**
     * 密码被修改
     */
    PASSWORD_CHANGED("password_changed", "密码被修改"),
    
    /**
     * 异地登录
     */
    REMOTE_LOGIN("remote_login", "异地登录"),
    
    /**
     * 系统维护
     */
    SYSTEM_MAINTENANCE("system_maintenance", "系统维护"),
    
    /**
     * 安全策略
     */
    SECURITY_POLICY("security_policy", "安全策略"),
    
    /**
     * 其他原因
     */
    OTHER("other", "其他原因");
    
    private final String code;
    private final String description;
    
    LogoutReasonEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }
    
    public String getCode() {
        return code;
    }
    
    public String getDescription() {
        return description;
    }
    
    /**
     * 根据code获取枚举
     */
    public static LogoutReasonEnum getByCode(String code) {
        for (LogoutReasonEnum reason : values()) {
            if (reason.getCode().equals(code)) {
                return reason;
            }
        }
        return OTHER;
    }
} 